<?
global $db;

$e = $db->query1("select * from node where folderid = ".$db->sqlint($params["folder"])." and folder = 0 and parentid = 0 order by orders limit 1");

$link = $e["id"];
if ($e["link"]) $link = $e["link"];
if ($e["folder"]) $link.="/";

header("Location: $link"); die;
#echo "<a href='$link'>click here</a>"; die;
?>